<script setup>
const props = defineProps({
  tabList: {
    type: Array,
    default: () => [],
  },
  activeTab: {
    type: [String, Number],
    default: '',
  },
})

const emit = defineEmits(['check'])

const checkTab = (item) => {
  console.log(item)
  emit('check', item.value)
}
</script>

<template>
  <view class="top-bar">
    <view
      v-for="item in tabList"
      :key="item.value"
      class="top-bar-item"
      :class="{ active: activeTab === item.value }"
      @click="checkTab(item)"
    >
      <view class="top-bar-item-text">{{ item.label }}</view>
      <image
        v-if="activeTab === item.value"
        class="top-bar-item-icon"
        src="/static/icons/top-bar-checked.png"
      />
    </view>
  </view>
</template>

<style lang="scss" scoped>
.top-bar {
  box-sizing: border-box;
  display: flex;
  align-items: baseline;
  height: 116rpx;
  padding: 24rpx 24rpx 0;
  overflow-x: auto;

  &-item {
    position: relative;
    flex-shrink: 0;
    padding: 0 20rpx;

    &-text {
      font-size: 28rpx;
      color: #fff;
    }

    &-icon {
      position: absolute;
      bottom: -36rpx;
      left: 50%;
      width: 32rpx;
      height: 32rpx;
      transform: translateX(-50%);
    }

    &.active {
      .top-bar-item-text {
        font-size: 36rpx;
        font-weight: 500;
        color: #fff;
      }
    }
  }
}
</style>
